package stopthread;

/**
 * @description:
 * @author: jhy
 * @time: 2021/4/11 22:23
 */
public class InterruptedDemo1 {

    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        myThread.start();
        myThread.interrupt();

        System.out.println("interrupted判断的是当前线程(执行当前代码的线程)是否中断" + myThread.interrupted());
        System.out.println("isInterrupted判断的是该线程对象是否中断"+myThread.isInterrupted());//true
        System.out.println("isInterrupted判断的是该线程对象是否中断"+myThread.isInterrupted());//true
        System.out.println("isInterrupted判断的是该线程对象是否中断"+myThread.isInterrupted());//true

    }
}

class MyThread1 extends Thread{
    @Override
    public void run() {
        for(int i = 0;i < 50000;i++){
            System.out.println("i=" + (i+1));
        }
    }
}
